/************************************* * File: fillUp.cpp * Author: Katherine Gibson * Date: 2/4/2016 * Section: N/A * E-mail: k38@umbc.edu * Description: * This program fills integer arrays * with one value via a function *************************************/ #include using namespace std; void fillUp(int array[], int size, int num); void printArray(int array[], int size); int main() { const int NUM_PRICES = 15; const int NUM_TIMES = 24; const int COST = 100; int prices[NUM_PRICES]; int times [NUM_TIMES ]; cout << "Before initializing: " << endl; printArray(prices, NUM_PRICES); printArray(times , NUM_TIMES ); fillUp(prices, NUM_PRICES, COST); fillUp(times , NUM_TIMES , 0); cout << endl << "After initializing: " << endl; printArray(prices, NUM_PRICES); printArray(times , NUM_TIMES ); return 0; } /* Name: fillUp * Pre : array is at least as large as size * size is positive (or 0) * Post: array is filled with value of num */ void fillUp(int array[], int size, int num) { for (int i = 0; i < size; i++) { array[i] = num; } } /* Name: printArray * Pre : array is at least as large as size * size is positive (or 0) * Post: array's contents up to size are * printed out on one line */ void printArray(int array[], int size) { for (int i = 0; i < size; i++) { cout << array[i] << " "; } cout << endl; }